﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RemoteTestRunner.BusinessLogic
{
    public class SelectedItem<T> : INotifyPropertyChanged
    {
        public SelectedItem(T item)
        {
            this.Item = item;
            PropertyChanged += new PropertyChangedEventHandler(SelectedItem_PropertyChanged);
        }

        public void SelectedItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
                default:
                    break;
            }
        }

        #region IsSelected (INotifyPropertyChanged Property)
        private bool _isSelected;
        public bool IsSelected
        {
            get { return _isSelected; }
            set
            {
                if (_isSelected != value)
                {
                    _isSelected = value;
                    OnPropertyChanged("IsSelected");
                }
            }
        }
        #endregion

        #region Item (INotifyPropertyChanged Property)
        private T _item;
        public T Item
        {
            get { return _item; }
            set
            {
                if (_item != null && _item.Equals(value))
                {
                    return;
                }
                _item = value;
                OnPropertyChanged("Item");
            }
        }
        #endregion

        #region INotifyPropertyChanged values

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion

    }
}